package com.bdzl.ecs.util;

import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.*;
import java.util.Properties;

/**
 * 获取配置属性工具类
 * @author HKXR-YFPC
 *
 */
public class PropertiesUtils {

	private static Resource resource = new ClassPathResource("config.properties");
	
	private static Properties properties = new Properties();
	
	/**
	 * 通过key 获取配置属性
	 * @param key
	 * @return
	 */
	public static String getKey(String key){
		String val = null;
		try {
			properties.load(new InputStreamReader(new BufferedInputStream(new FileInputStream(resource.getFile())),"UTF-8"));
			val =  properties.getProperty(key);
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return val;
	}
	
}
